git-annex
git-annex-shell
git-remote-annex
+git-remote-p2p-annex
git-remote-tor-annex
man
doc/.ikiwiki
unlessM (boolSystem "strip" [File (fromOsPath (bindir </> literalOsPath "git-annex"))]) $
error "strip failed"
createSymbolicLink "git-annex" (fromOsPath (bindir </> literalOsPath "git-annex-shell"))
+ createSymbolicLink "git-annex" (fromOsPath (bindir </> literalOsPath "git-remote-p2p-annex"))
createSymbolicLink "git-annex" (fromOsPath (bindir </> literalOsPath "git-remote-tor-annex"))
createSymbolicLink "git-annex" (fromOsPath (bindir </> literalOsPath "git-remote-annex"))
* p2p: Added --enable option, which can be used to enable P2P networks
provided by external commands git-annex-p2p-<netname>
+ * Added git-remote-p2p-annex, which allows git pull and push to
+ P2P networks provided by external commands.
-- Joey Hess <id@joeyh.name> Wed, 30 Jul 2025 13:45:42 -0400
--- /dev/null
+{- git-remote-p2p-annex program
+ -
+ - Copyright 2016-2025 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU AGPL version 3 or higher.
+ -}
+
+module CmdLine.GitRemoteP2PAnnex where
+
+import Common
+import qualified Annex
+import qualified Git.CurrentRepo
+import P2P.Protocol
+import P2P.IO
+import Utility.AuthToken
+import Annex.UUID
+import P2P.Address
+import P2P.Auth
+import Annex.Action
+
+run :: [String] -> IO ()
+run = runner mkaddress
+ where
+ mkaddress address =
+ fromMaybe (error $ "unable to parse address: " ++ address) $
+ unformatP2PAddress (p2pAnnexScheme ++ ":" ++ address)
+
+runner :: (String -> P2PAddress) -> [String] -> IO ()
+runner mkaddress (_remotename:saddress:[]) = forever $
+ getLine >>= \case
+ "capabilities" -> putStrLn "connect" >> ready
+ "connect git-upload-pack" -> go UploadPack
+ "connect git-receive-pack" -> go ReceivePack
+ l -> giveup $ "gitremote-helpers protocol error at " ++ show l
+ where
+ address = mkaddress saddress
+ go service = do
+ ready
+ connectService address service >>= \case
+ Right exitcode -> exitWith exitcode
+ Left e -> giveup $ describeProtoFailure e
+ ready = do
+ putStrLn ""
+ hFlush stdout
+runner _ (_remotename:[]) = giveup "remote address not configured"
+runner _ _ = giveup "expected remote name and address parameters"
+
+connectService :: P2PAddress -> Service -> IO (Either ProtoFailure ExitCode)
+connectService address service = do
+ state <- Annex.new =<< Git.CurrentRepo.get
+ Annex.eval state $ do
+ authtoken <- fromMaybe nullAuthToken
+ <$> loadP2PRemoteAuthToken address
+ myuuid <- getUUID
+ g <- Annex.gitRepo
+ conn <- liftIO $ connectPeer (Just g) address
+ runst <- liftIO $ mkRunState Client
+ r <- liftIO $ runNetProto runst conn $ auth myuuid authtoken noop >>= \case
+ Just _theiruuid -> connect service stdin stdout
+ Nothing -> giveup $ "authentication failed, perhaps you need to set " ++ p2pAuthTokenEnv
+ quiesce False
+ return r
module CmdLine.GitRemoteTorAnnex where
import Common
-import qualified Annex
-import qualified Git.CurrentRepo
-import P2P.Protocol
-import P2P.IO
import Utility.Tor
-import Utility.AuthToken
-import Annex.UUID
import P2P.Address
-import P2P.Auth
-import Annex.Action
+import CmdLine.GitRemoteP2PAnnex (runner)
run :: [String] -> IO ()
-run (_remotename:address:[]) = forever $
- getLine >>= \case
- "capabilities" -> putStrLn "connect" >> ready
- "connect git-upload-pack" -> go UploadPack
- "connect git-receive-pack" -> go ReceivePack
- l -> giveup $ "gitremote-helpers protocol error at " ++ show l
+run = runner mkaddress
where
- (onionaddress, onionport)
- | '/' `elem` address = parseAddressPort $
- reverse $ takeWhile (/= '/') $ reverse address
- | otherwise = parseAddressPort address
- go service = do
- ready
- connectService onionaddress onionport service >>= \case
- Right exitcode -> exitWith exitcode
- Left e -> giveup $ describeProtoFailure e
- ready = do
- putStrLn ""
- hFlush stdout
-
-run (_remotename:[]) = giveup "remote address not configured"
-run _ = giveup "expected remote name and address parameters"
+ mkaddress address =
+ let (onionaddress, onionport)
+ | '/' `elem` address = parseAddressPort $
+ reverse $ takeWhile (/= '/') $ reverse address
+ | otherwise = parseAddressPort address
+ in TorAnnex onionaddress onionport
parseAddressPort :: String -> (OnionAddress, OnionPort)
parseAddressPort s =
in case readish sp of
Nothing -> giveup "onion address must include port number"
Just p -> (OnionAddress a, p)
-
-connectService :: OnionAddress -> OnionPort -> Service -> IO (Either ProtoFailure ExitCode)
-connectService address port service = do
- state <- Annex.new =<< Git.CurrentRepo.get
- Annex.eval state $ do
- authtoken <- fromMaybe nullAuthToken
- <$> loadP2PRemoteAuthToken (TorAnnex address port)
- myuuid <- getUUID
- g <- Annex.gitRepo
- conn <- liftIO $ connectPeer (Just g) (TorAnnex address port)
- runst <- liftIO $ mkRunState Client
- r <- liftIO $ runNetProto runst conn $ auth myuuid authtoken noop >>= \case
- Just _theiruuid -> connect service stdin stdout
- Nothing -> giveup $ "authentication failed, perhaps you need to set " ++ p2pAuthTokenEnv
- quiesce False
- return r
{- git-annex multicall binary
-
- - Copyright 2024 Joey Hess <id@joeyh.name>
+ - Copyright 2024-2025 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
data OtherMultiCallCommand
= GitAnnexShell
| GitRemoteAnnex
+ | GitRemoteP2PAnnex
| GitRemoteTorAnnex
otherMulticallCommands :: M.Map String OtherMultiCallCommand
otherMulticallCommands = M.fromList
[ ("git-annex-shell", GitAnnexShell)
, ("git-remote-annex", GitRemoteAnnex)
+ , ("git-remote-p2p-annex", GitRemoteP2PAnnex)
, ("git-remote-tor-annex", GitRemoteTorAnnex)
]
-all=git-annex git-annex-shell git-remote-annex git-remote-tor-annex mans docs
+all=git-annex git-annex-shell git-remote-annex git-remote-p2p-annex git-remote-tor-annex mans docs
# set to "./Setup" if you lack a cabal program. Or can be set to "stack"
BUILDER?=cabal
git-remote-annex: git-annex
@ln -sf git-annex git-remote-annex
+git-remote-p2p-annex: git-annex
+ @ln -sf git-annex git-remote-p2p-annex
+
git-remote-tor-annex: git-annex
@ln -sf git-annex git-remote-tor-annex
ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell
ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-remote-annex
ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-remote-tor-annex
+ ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-remote-p2p-annex
install-desktop: build Build/InstallDesktopFile
./Build/InstallDesktopFile $(PREFIX)/bin/git-annex || true
CmdLine.AnnexSetter
CmdLine.Multicall
CmdLine.GitRemoteAnnex
+ CmdLine.GitRemoteP2PAnnex
CmdLine.GitRemoteTorAnnex
CmdLine.Option
CmdLine.Seek
import qualified CmdLine.GitAnnex
import qualified CmdLine.GitAnnexShell
import qualified CmdLine.GitRemoteAnnex
+import qualified CmdLine.GitRemoteP2PAnnex
import qualified CmdLine.GitRemoteTorAnnex
import qualified Test
import qualified Benchmark
run ps n = case M.lookup (takeFileName n) otherMulticallCommands of
Just GitAnnexShell -> CmdLine.GitAnnexShell.run ps
Just GitRemoteAnnex -> CmdLine.GitRemoteAnnex.run ps
+ Just GitRemoteP2PAnnex -> CmdLine.GitRemoteP2PAnnex.run ps
Just GitRemoteTorAnnex -> CmdLine.GitRemoteTorAnnex.run ps
Nothing -> CmdLine.GitAnnex.run
Test.optParser
# The bundled git does not work well on sdcard, so delete
# it and use termux's git which works better.
cd "$base"
- find . | grep git | grep -v git-annex | grep -v git-remote-annex | grep -v git-remote-tor-annex | grep -v git-remote-gcrypt | xargs rm -rf
+ find . | grep git | grep -v git-annex | grep -v git-remote-annex | grep -v git-remote-p2p-annex | grep -v git-remote-tor-annex | grep -v git-remote-gcrypt | xargs rm -rf
# Use termux's uname, which knows it's on android,
# not the bundled one.
rm -f bin/uname